package org.example;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import org.example.model.TableLineage;

import java.util.List;

public class MetadataClient {

    private String address;


    public MetadataClient(String address) {
        this.address = address;
    }

    public void sub(List<TableLineage> tableLineages){

        HttpUtil.createPost(address+"/api/openApi/lineage/pushLineages")
                .body(JSON.toJSONString(tableLineages)).execute().body();
    }

    public     void pushSql(String ip,String port,String sql){

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("ip",ip);
        jsonObject.put("port",port);
        jsonObject.put("sql",sql);
        HttpUtil.createPost(address+"/api/openApi/lineage/pushSql")
                .body(JSON.toJSONString(jsonObject)).execute().body();
    }



}
